﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace XmlParsingExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var _leagueTableUrl = "http://www.managerzone.com/xml/team_league.php?sport_id=1&league_id=56138";
            var _matchesListUrl = "http://www.managerzone.com/xml/team_matchlist.php?sport_id=1&team_id=306077&match_status=1&limit=50";
            var _playersListUrl = "http://www.managerzone.com/xml/team_playerlist.php?sport_id=1&team_id=306077";
            var _managerInfoUrl = "http://www.managerzone.com/xml/manager_data.php?sport_id=1&user_id=8195557&username=leacasas&team_id=306077";
            var _matchInfoUrl = "http://www.managerzone.com/xml/match_info.php?sport_id=1&match_id=664052507";
            var reader = new XmlTextReader(_matchInfoUrl);
            while(reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // El nodo es un elemento.
                        Console.Write("<" + reader.Name);
                        while (reader.MoveToNextAttribute()) // Lee los atributos.
                            Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                        Console.WriteLine(">");
                        break;
                    case XmlNodeType.Text: //Muestra el texto en cada elemento.
                        Console.WriteLine(reader.Value);
                        break;
                    case XmlNodeType.EndElement: //Muestra el final del elemento.
                        Console.Write("</" + reader.Name);
                        Console.WriteLine(">");
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}